package com.xwtec.juc.c_006;

import java.util.concurrent.TimeUnit;

/**
 * @Author: zt
 * @Date: 2021/3/19 16:25
 */
public class T {

    public synchronized void m1(){
        System.out.println("m1 started");
        try {
            TimeUnit.MILLISECONDS.sleep(10000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("m1 end");
    }

    public void m2(){
        try {
            TimeUnit.MILLISECONDS.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("m2 excu");
    }


    public static void main(String[] args) {
        T t = new T();
        new Thread(t::m1,"Thread_m1").start();
        new Thread(t::m2,"Thread_m2").start();
    }
}
